import axios from "../util/request";

export function getCompanyList(val) {
  return axios({
    url: `/adminapi/freight/express?keyword=${val.keyword}&page=${val.page}&limit=${val.limit}`,
    method: "get",
  });
}

export function addModel(val) {
  return axios({
    url: "/adminapi/freight/express/create",
    method: "get",
  });
}

export function delCompany(val) {
  return axios({
    url: "/adminapi/freight/express/" + val,
    method: "DELETE",
  });
}

export function addQ(val) {
  const { name, sort, code, is_show } = val;
  return axios({
    url: "/adminapi/freight/express",
    method: "post",
    data: { code, is_show, name, sort },
  });
}

export function editCompanyList(val) {
  return axios({
    url: `/adminapi/freight/express/${val}/edit`,
    method: "get",
  });
}

export function conEdit(val) {
  const { id, name, sort, code, is_show } = val;
  return axios({
    url: `/adminapi/freight/express/` + id,
    method: "PUT",
    data: { code, is_show, name, sort },
  });
}

export function getCityList(val) {
  return axios({
    url: `/adminapi/setting/city/list/` + val,
    method: "get",
  });
}

export function delCityList(val) {
  return axios({
    url: `/adminapi/setting/city/list/` + val,
    method: "get",
  });
}

export function citySwicthChange(val) {
  console.log(val);
  return axios({
    url: `/adminapi/freight/express/set_status/${val.id}/${val.is_show}`,
    method: "put",
  });
}

export function clearCache() {
  return axios({
    url: `/adminapi/setting/city/clean_cache`,
    method: "get",
  });
}

export function addCity() {
  return axios({
    url: `/adminapi/setting/city/add/0`,
    method: "get",
  });
}

export function editCity(val) {
  return axios({
    url: `/adminapi/setting/city/${val}/edit`,
    method: "get",
  });
}

export function delCity(val) {
  return axios({
    url: `/adminapi/setting/city/del/` + val,
    method: "DELETE",
  });
}

export function confirmEdit(val) {
  const { level, name, parent_id, parent_name, id, merger_name } = val;
  return axios({
    url: `/adminapi/setting/city/save`,
    method: "post",
    data: {
      level,
      parent_id,
      name,
      id,
      merger_name,
      parent_name,
    },
  });
}

export function confirmAdd(val) {
  const { level, name, parent_id, parent_name } = val;
  return axios({
    url: `/adminapi/setting/city/save`,
    method: "post",
    data: {
      level,
      parent_id,
      name,
      parent_name,
    },
  });
}
